package com.xxxx.system.index.Controller

import com.xxxx.system.index.model.CContract
import com.xxxx.system.index.service.CContractService
import org.apache.hadoop.hbase.util.Bytes
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.hadoop.hbase.HbaseTemplate
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseBody

@Controller
@RequestMapping("test_index")
class TestController {
    @Autowired
    private lateinit var hbasetemplate: HbaseTemplate
    @Autowired
    private lateinit var cContraceService:CContractService

    @RequestMapping("/test_one")
    @ResponseBody
    fun test(): String {
      //  javax.servlet.jsp.JspFactory
        /* hbasetemplate.get("test_hbase","test1", RowMapper<T>(){

        })*/
        try {
          hbasetemplate.put("test_hbase", "002", "test1", "pro", Bytes.toBytes("yuanpin"))
           /* var res = hbasetemplate.get("test_hbase", "test1", "names", RowMapper<String>(
                    fun(var1: Result, var2: Int): String {
                        return "123"
                    })

            )*/
            // HBaseJavaAPI.addRow("test_hbase","001","test1","indexss","index222")
           // HBaseJavaAPI.delRow("test_hbase","002")
             var datas = HBaseJavaAPI.getRow("test_hbase","001")
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return ""
    }

    @RequestMapping("test_two")
    fun test_two(int_id:String):String{
        val selectByIntPrimaryKeyObj = cContraceService.selectByIntPrimaryKeyObj(Integer.parseInt(int_id))
        return "index"
    }

}